type CalcType = (num1: number, num2: number) => number;
function calc(calcFn: CalcType) {
  const num1 = 10;
  const num2 = 20;
  //(但是在调用时参数不能少)
  const res = calcFn(num1, num2);
  console.log(res);
}

//一个参数也没有，也不报错，多余的参数会进行报错
//类似forEach的例子，我们只用item，不需要吧参数全部参数列举出来(index,arr不需要写出来)
//forEach默认传的也是匿名函数(但是在调用时参数不能少)
calc(function (num1) {
  return 123;
});
function foo() {
  return 123;
}
calc(foo);

//在举个例子,下面定义一个p给Info赋值就不会报错
//取决于内部的规则
interface IPerson {
  name: string;
  age: number;
}

//ts会报错,
// const info1: IPerson = {
//   name: "why",
//   age: 18,
//   height: 1.88,
//   address: "安徽省",
// };

//这里不会报错
const p = {
  name: "why",
  age: 18,
  height: 1.88,
  address: "安徽省",
};
const info: IPerson = p;

export {};
